<html>
<head>
<title>Back Order List Result</title>
<style type="text/css">
body {
	font-family:verdana,arial,sans-serif;
	font-size:10pt;
	margin:30px;
	background-color:#ffcc00;
	}
</style>
</head>
<body>
<h1>List Of Back Orders</h1><br />
<?php
date_default_timezone_set('UTC');

$username="bsc353_4";
$password="sonbeans";
$database="bsc353_4";

$groupby= ($_POST['groupBySelect']);
$var = "";

if ($groupby = 'customerID')
    $var = "Customer.ID";
else if ($groupby = 'bookSubject')
    $var = "Book.subject";
else
    $var = "Orders.storeBranchID";

mysql_connect("clipper.encs.concordia.ca",$username,$password) or die ("Unable to connect to database");

// Check connection
@mysql_select_db($database) or die ("Unable to select database");

$query="SELECT * FROM Orders JOIN Customer ON Orders.customerID = Customer.ID JOIN Book ON Orders.ISBN = Book.ISBN WHERE Orders.status = 'Requested' ORDER BY $var";
//echo"$query";
$result=mysql_query($query) or die ("Query Failed");
$num=mysql_numrows($result);
mysql_close();

?>

<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td><font face="Arial, Helvetica, sans-serif">Order Number</font></td>
<td><font face="Arial, Helvetica, sans-serif">ISBN</font></td>
<td><font face="Arial, Helvetica, sans-serif">Publisher</font></td>
<td><font face="Arial, Helvetica, sans-serif">Book Title</font></td>
<td><font face="Arial, Helvetica, sans-serif">Subject</font></td>
<td><font face="Arial, Helvetica, sans-serif">Author</font></td>
<td><font face="Arial, Helvetica, sans-serif">Quantity</font></td>
<td><font face="Arial, Helvetica, sans-serif">Customer ID</font></td>
<td><font face="Arial, Helvetica, sans-serif">Customer Name</font></td>
<td><font face="Arial, Helvetica, sans-serif">Customer Address</font></td>
<td><font face="Arial, Helvetica, sans-serif">Store Branch ID</font></td>
</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"Orders.orderNumber");
$f2=mysql_result($result,$i,"Orders.ISBN");
$f3=mysql_result($result,$i,"Book.publisher");
$f4=mysql_result($result,$i,"Book.title");
$f5=mysql_result($result,$i,"Book.subject");
$f6=mysql_result($result,$i,"Book.author");
$f7=mysql_result($result,$i,"Orders.quantity");
$f8=mysql_result($result,$i,"Orders.customerID");
$f9=mysql_result($result,$i,"Customer.name");
$f10=mysql_result($result,$i,"Customer.address");
$f11=mysql_result($result,$i,"Orders.storeBranchID");

?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f7; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f8; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f9; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f10; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f11; ?></font></td>
</tr>

<?php
$i++;
}
?>
</body>
</html>
